package org.isima.ui.faces.bean.documents;

import java.io.Serializable;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import org.isima.ui.faces.service.DirectoryService;
import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;

@ManagedBean
@ApplicationScoped
public class DirectoriesTreeBean implements Serializable {
	
	private static final long serialVersionUID = 1L;
	private TreeNode root;
	private TreeNode selectedNode;
	private DirectoryService service;
	
	public TreeNode getSelectedNode() {
		return selectedNode;
	}
	
	public void setSelectedNode(TreeNode selectedNode) {
		this.selectedNode = selectedNode;
	}

	public TreeNode getRoot() {
		return root;
	}

	public void setRoot(TreeNode root) {
		this.root = root;	
	}
	
	/**
	 * Creation d'un arbre a partir de root (qu'il faut preciser)
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 */
	public DirectoriesTreeBean() throws InstantiationException, IllegalAccessException {
		service = new DirectoryService();
		root = new DefaultTreeNode("Root", null);
		service.doFindAll(root, "/Users/Axelle/Desktop");
	}
}
